package lumis.portal.webfilereplication;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lumis.portal.event.persistence.PortalEventEntityListener;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

/**
 * Custom property value of a web file replication.
 * 
 * @version $Revision: 13093 $ $Date: 2011-05-28 18:40:18 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "lum_WFRPropValue")
@GenericGenerator(name = "portal-guid", strategy = "lumis.portal.dao.hibernate.GuidGenerator")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@EntityListeners(value = PortalEventEntityListener.class)
public class WebFileReplicationPropertyValue implements Serializable
{
	@Id
	@GeneratedValue(generator = "portal-guid")
	private String id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "replicationId", nullable = false)
	private WebFileReplication replication;

	@ManyToOne(fetch = FetchType.EAGER)
	@BatchSize(size = 500)
	@JoinColumn(name = "propertyId", nullable = false)
	private WebFileReplicationProperty property;

	private String value;

	/**
	 * Returns the identifier of the value.
	 * 
	 * @return the identifier of the value.
	 * @since 6.0.0
	 */
	public String getId()
	{
		return id;
	}
	
	/**
	 * Returns the web file replication that owns the property.
	 * 
	 * @return the web file replication that owns the property.
	 * @since 6.0.0
	 */
	public WebFileReplication getReplication()
	{
		return this.replication;
	}

	/**
	 * Defines the web file replication that owns the property.
	 * 
	 * @param replication
	 *            the web file replication to be defined.
	 * @since 6.0.0
	 */
	public void setReplication(WebFileReplication replication)
	{
		this.replication = replication;
	}

	/**
	 * Returns the value of the property.
	 * 
	 * @return the value of the property.
	 * @since 6.0.0
	 */
	public String getValue()
	{
		return value;
	}

	/**
	 * Defines the value of the property.
	 * 
	 * @param value
	 *            the value to be defined.
	 * @since 6.0.0
	 */
	public void setValue(String value)
	{
		this.value = value;
	}

	/**
	 * Returns the property associated with the value.
	 * 
	 * @return the property associated with the value.
	 * @since 6.0.0
	 */
	public WebFileReplicationProperty getProperty()
	{
		return this.property;
	}

	/**
	 * Defines the property associated with the value.
	 * 
	 * @param property
	 *            the property to be defined.
	 * @since 6.0.0
	 */
	public void setProperty(WebFileReplicationProperty property)
	{
		this.property = property;
	}
}
